<?php

	require_once 'googleOptions.php';
	require_once 'googleSearch.php';
	require_once 'searchParser.php';
	require_once 'searchPager.php';


//Example

	$search	=	new googleSearch();							//An instance of our search proxy
	$search->setQuery('pijonga');								//Search term, usually, something like user input
	$search->setStart(0);										//Paging, start page (see the pager class)
	$search->setLanguage('de');								//This defaults to english if you dont set it
	$search	=	$search->doGoogleSearch();					//Do the search!

	try { 

		$template	=	new searchParser($search,'resources/templates/');	//Parse the search, 
		$template	=	$template->getSmartyObject();		//Get the Smarty Object!;

		$pager		=	new searchPager ($search);			//Create a new pager instance, we have to assign it to our template! else we wont be able to do the paging
		$pager->setPage('gsearch.php?page=%s');			//Set the base URL so the pager can actually now where does it has to page, %s gets replaced with the page number

		$template->assign('pager',$pager->display());	//Assign the pager to the template in order to show it
		echo $template->fetch ('search.tpl');				//Display The contents

	} catch (Exception $e) {

		var_dump( $e->getMessage());							//dump the error, if any

	}

?>
